package com.cee.quartz.config;

import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.spi.JobFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.PropertiesFactoryBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;
import org.springframework.scheduling.quartz.SchedulerFactoryBean;
 
import java.io.IOException;
import java.io.Serializable;
import java.util.Properties;
 
 
/**
 * @Description
 */
//@Configuration
//public class QuartzConfig {
//
//    @Autowired
//    private JobFactory jobFactory;
//
//
//    @Bean
//    public Properties quartzProperties() throws IOException {
//        PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean();
//        propertiesFactoryBean.setLocation(new ClassPathResource("/spring.quartz.yml"));
//        propertiesFactoryBean.afterPropertiesSet();
//        return propertiesFactoryBean.getObject();
//    }
//
//
//    @Bean
//    public SchedulerFactoryBean schedulerFactoryBean() throws IOException {
//        SchedulerFactoryBean schedulerFactoryBean = new SchedulerFactoryBean();
//
//        schedulerFactoryBean.setOverwriteExistingJobs(true);
//        schedulerFactoryBean.setQuartzProperties(quartzProperties());
//        schedulerFactoryBean.setJobFactory(jobFactory);
//
//        return schedulerFactoryBean;
//    }
//
//
//    // 创建schedule
//    @Bean(name = "scheduler")
//    public Scheduler scheduler() throws IOException {
//        try {
//            Scheduler scheduler = schedulerFactoryBean().getScheduler();
//             scheduler.startDelayed(5);
//            return scheduler;
//        } catch (SchedulerException e) {
//           throw new RuntimeException(e);
//        }
//
//    }
//}
